<template>
	<view class="content">
		<view>
			
		</view>
		<mSidebar title="当前请假进度">
			<view class="row">
				<m-steps v-for="(item, index) in wrapRecordList" 
					:item='item'
					:key="index" 
					:index='index' 
					:activity= 'activity' 
					date='leaveApprovalTime'>
					<text slot="status">{{item.leaveApprovalRecord}}</text>
				</m-steps>
			</view>
		</mSidebar>
	</view>
</template>

<script>
	import mSidebar from "../../components/m-sidebar/m-sidebar.vue"
	import mSteps from '../../components/m-steps/m-steps.vue'
	import * as api from '../config/api.js'
	import { timestampToTime } from '../utils/timeToTime.js'
	import { progressStatus } from '../../data/data.js'
	export default {
		components: {
		    mSidebar,
		    mSteps
		},
		data(){
			return{
				// 当前进度，显示亮球,建议默认显示最新进度
				activity: 0,
				// 流程数组
				wrapRecordList:[],
				progressStatus:progressStatus
				// 0 开始， 1 准备出发 2 到达中转站 3 送往目的地 4 已送达
			}
		},
		onShow() {
			this.getNowListInfo()
		},
		onLoad() {
			this.$reoladUser()
			this.getNowListInfo()
		},
		methods:{
			getNowListInfo(){
				let leaveUserNum = uni.getStorageSync('leaveUserNum')
				let that = this;
				api.getNowFlowByUserNumApi(leaveUserNum,{
					data:{},
					success:res=>{
						// console.log(res)
						if(res.code == 200){
							// console.log(res)
							let list = res.data;
							for(var i = 0 ; i < list.length; i++){
								// 时间戳转换
								list[i].leaveApprovalTime = timestampToTime(list[i].leaveApprovalTime)
							}
							// console.log(list)
							that.wrapRecordList = list
						}else if(res.code == 500){
							uni.showToast({
								title:"暂无请假数据",
								icon:"none"
							})
						}else{
							uni.showToast({
								title:"请求失败",
								icon:"none"
							})
						}
						
					},
					fail:err=>{
						
					}
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	page{
		width: 100%;
		height: 100%;
		background-color: white;
	}
	.content {
		padding: 40rpx;
		.row {
			padding: 24rpx 0;
		}
	}
</style>
